from mysql.connector import connect, Error
import os

DB_CONFIG = {
    "host": os.getenv("TIMER_DB_HOST", "172.22.151.137"),
    "port": int(os.getenv("TIMER_DB_PORT", "3306")),
    "user": os.getenv("TIMER_DB_USER", "root"),
    "password": os.getenv("TIMER_DB_PASSWORD", "123456"),
    "database": os.getenv("TIMER_DB_NAME", "timer_db"),
}

try:
    conn = connect(**DB_CONFIG)
    print("连接成功！")
    conn.close()
except Error as e:
    print(f"连接失败: {e}")
